<?php
/**
 * @Copyright   2008, XXXX-XXXX
 * All rights reserved. 
 * feature summary.
 * @filesource  TopCommand.php 
 * @author      lipeng <lipengage@gmain.com> 
 * @package     / 
 * @version     $Id: $ 
 */

class TopCommand extends command{
	public function excute() {
		$userdb = new user_dao();
		$viewerid = $this->request['masterid'];
		$container = $this->request['container'];
		
		if (empty($viewerid) || empty($container)) {
			$this->set_messageid(command::$PARAM_ERROR);
			$this->set_params(null);
			return true;
		}
		$viewer = $userdb->user_get_byid($container, $viewerid);
		if ($viewer['count'] < 1 || $slave['count'] < 1) {
			$this->set_messageid(command::$PLAYER_NOT_FOUND);
			$this->set_params(null);
			return true;
		} 
		else {
			$viewer = $viewer['result'][0];
		}

		$sort = $this->request["sort"];
		$friends = $this->request["friends"];
		$top = $this->request["top"];
		$top = (intval($top) < 1) ? 20 : $top;

		$friends_list = $this->userdb->user_get_bytop($container, $friends, $sort, $max);
		if ($friends_list["count"] < 1) {
		}
		else {
			$params = $friends_list["result"];
		}
		
		$this->set_haserror(false);
		$this->set_params($params);
		return true;
		//{"haserror":true,"messageid":"string","params":{"viewer":{},"slave":{},"oldmaster":{}}}
	}
}
?>